home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre1.z / postgre1 / test / postfs / dump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  599 b   |  33 lines

  1. #include "tmp/libpq-fs.h"
  2. #include  <sys/file.h>
  3.  
  4. extern char *PQexec();
  5.  
  6. void main(argc,argv)
  7.      int argc;       
  8.      char *argv[];
  9. {
  10.     int fd;
  11.     int cnt, total = 0;
  12.     char *buf;
  13.     int blen;
  14.     char *res;
  15.     extern char *getenv();
  16.  
  17.     PQsetdb(getenv("USER"));
  18.     blen=atoi(argv[2]);
  19.     buf = (char *)malloc(blen);
  20.  
  21.     res = PQexec("begin");
  22.     fd = p_open(argv[1],O_RDONLY);
  23.     printf("%d fd\n",fd);
  24.     while ((cnt = p_read(fd,buf,blen)) > 0) {
  25.     printf ("%d\n",cnt);
  26.     total += cnt;
  27.     printf ("%d total\n",total);
  28.     }
  29.     p_close(fd);
  30.     res = PQexec("end");
  31.     PQfinish();
  32. }
  33.